<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>
//原始数据
let header = ["手机号","姓名","入职日期","转正日期","工号"]
let results = [{"手机号":13941130879,"姓名":"高大山","入职日期":43535,"转正日期":43719,"工号":20089}]

// 旧对象的字段对应新对象的字段数组
const userRelations = {
  '入职日期': 'timeOfEntry',
  '手机号': 'mobile',
  '姓名': 'username',
  '转正日期': 'correctionTime',
  '工号': 'workNumber'
}

//目标数据
// let = data = [{mobile: '13941130879','username': '高大山', '...'}, {...}]

// let item = {}
// for(let key in results[0]){
//   console.log(key);
//   let newKey = userRelations[key]
//   console.log(newKey);
//   // 把旧对象的key对应的值传给字段匹配的新对象中去
//   results[0][newKey] = results[0][key]
//   // 并把旧对象相关key及数据删除
//   delete results[0][key]

//   // item = results[0][key]
// }
// console.log(results[0]);

// 最终
let data = results.map(t => {
  let item = {}
  for(let k in t) {
    // userRelations[k] 新key
    // t[k] 旧key对应的value
    // item[userRelations[k]] 新key对应的value
    item[userRelations[k]] = t[k]
  }
  return item
})
console.log(data);
</script>
</html>
